import requests


class KDTXApi:

    # 封装一个生成验证码接口
    @classmethod
    def get_code_api(cls):
        url = "http://kdtx-test.itheima.net/api/captchaImage"
        resp = requests.get(url)
        return resp
        pass

    # 封装登录的接口
    @classmethod
    def login_api(cls,body):
        url = "http://kdtx-test.itheima.net/api/login"
        header = {"content-type": "application/json"}
        resp =requests.post(url=url,headers=header,json=body)
        return resp
        pass

    #合同上传
    @classmethod
    def upload_contract_api(cls,token,f):
        url="http://kdtx-test.itheima.net/api/common/upload"
        header={"Authorization":token}
        resp =requests.post(url=url,headers=header,files={"file":f})
        return resp


    #新增合同
    @classmethod
    def add_contract_api(cls,token,body):
        url="http://kdtx-test.itheima.net/api/contract"
        header={"content-type":"application/json","Authorization":token}
        resp = requests.post(url=url,headers=header,json=body)
        return resp
        pass


    #查询合同列表
    @classmethod
    def query_contract_api(cls,token):
        url = "http://kdtx-test.itheima.net/api/contract/list"
        header = {"Authorization": token}
        resp =requests.get(url=url,headers=header)
        return resp
        pass


    #删除合同
    @classmethod
    def del_contract_api(cls,token,body):
        url = "http://kdtx-test.itheima.net/api/contract/remove"
        header={"content-type":"application/x-www-form-urlencoded","Authorization":token}
        resp =requests.post(url=url,headers=header,data=body)
        return resp
        pass

    pass
